﻿/*
 This file was create by Xusion at 01.06.2011
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeiBo.SinaAPI
{
    public static class StringHelper
    {
        /// <summary>
        /// Utc时间转本地时间
        /// </summary>
        /// <param name="strValue">原格式：Wed Nov 17 15:07:48 +0800 2010</param>
        /// <returns></returns>
        public static string SplitDateTime(string strValue)
        {
            if (!string.IsNullOrEmpty(strValue))
            {
                //原格式：Wed Nov 17 15:07:48 +0800 2010
                string[] str = strValue.Split(' ');
                //转格式：Wed Nov 17 2010 15:07:48
                return str[0] + " " + str[1] + " " + str[2] + " " + str[5] + " " + str[3];
            }
            else
            {
                return "";
            }
        }
        /// <summary>
        /// 将新浪时间转换成 11月5日 14:23 格式
        /// </summary>
        /// <param name="sinaDate"></param>
        /// <returns></returns>
        public static string SinaDataConvert(string sinaDate)
        {
            //string sinaDate = "Thu Oct 06 20:28:33 +0800 2011"; //新浪的时间
            string newDate =SplitDateTime(sinaDate);
            DateTime newd = Convert.ToDateTime(newDate);
            System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;
            DateTime dt1 = DateTime.Now;
            string da = string.Format("{0:M}", newd);//11月5日
            string db = string.Format("{0:t}", newd);//14:23
            string result = da + " " + db;
            return result;
        }
       
    }
}
